package test;

import java.util.*;

public class ArrayWork {
    public static void main(String[] args) {

        HashMap<String, Integer> hashMap = new HashMap();
        List<String> list = Arrays.asList("a", "b", "a", "b", "c", "a", "b", "c", "b");
        HashSet<String> hashSet = new HashSet();
        hashSet.addAll(list);
        for (String obj : hashSet) {
            int n = 0;
            for (int j = 0; j < list.size(); j++) {
                if (obj.equals(list.get(j))) {
                    n++;
                }
                hashMap.put(obj, n);
            }
        }

        Set keyset = hashMap.keySet();
        for (Object key : keyset) {
            System.out.println(key + ":" + hashMap.get(key));
        }

    }
}
